﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Role.Entity;

namespace Role.Data
{
    public class ProductRepository : RoleRepositoryBase, IGetModel<Product>
    {
        /// <summary>
        /// 得到标准结果集
        /// </summary>
        /// <returns></returns>
        public IQueryable<Product> GetModel()
        {
            return base.GetEntities<Product>().OrderByDescending(i => i.ID);
        }
        /// <summary>
        /// 得到详细结果集
        /// </summary>
        /// <returns></returns>
        public IQueryable<Product> GetDetailModel()
        {
            var linq = from data1 in base.GetEntities<Product>()
                       join data2 in new WorkFlow_InfoRepository().GetDetailModel() on data1.WorkFlowID equals data2.ID
                       select new Product_Ext
                       {
                           ID            = data1.ID,
                           Info          = data1.Info,
                           Name          = data1.Name,
                           WorkFlow_Info = data2,
                           WorkFlowID    = data1.WorkFlowID,
                       };
            return linq;
        }
    }
}
